﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WhittleList.Bll;

namespace WhittleList.Tests.Mocks
{
    public class FakeItem : Moq.Mock<Item>
    {
        public static List<FakeItem> GetList(int number)
        {
            return GetList(number, new Random());
        }

        public static List<FakeItem> GetList(int number, Random rnd)
        {
            var tmp = new List<FakeItem>();
            while (tmp.Count < number)
            {
                var i = tmp.Count + 1;
                tmp.Add(new FakeItem(i, string.Format("Item {0}", i), string.Format("Item {0} Notes", i), i+10, Helpers.MockHelpers.CreateBinary(rnd)));
            }
            return tmp;

        }

        public FakeItem(int id, string name, string notes, int importance, System.Data.Linq.Binary cid)
        {
            Setup(x => x.Id).Returns(id);
            SetupProperty(x => x.Name, name);
            Setup(x => x.CID).Returns(cid);
            SetupProperty(x => x.Notes, notes);
            SetupProperty(x => x.Importance, importance);

        }

        internal void SetSection(FakeSection section)
        {
            Setup(x => x.Section).Returns(section.Object);
            Setup(x => x.SectionId).Returns(section.Object.Id);
        }
    }
}
